<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" type="text/css"
        href="jquery-easyui-1.3.3/themes/default/easyui.css">
  <link rel="stylesheet" type="text/css"
        href="jquery-easyui-1.3.3/themes/icon.css">
  <link rel="icon" href="">
  <script type="text/javascript"
          src="jquery-easyui-1.3.3/jquery.min.js"></script>
  <script type="text/javascript"
          src="jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
  <script type="text/javascript"
          src="js/common.js"></script>
  <script type="text/javascript">
    $.getJSON("admins/1", null, function(data) {
      console.log(data);
      $("#adminid").val(data.id);
      $("#username").val(data.username);
      $("#rolename").val(data.rolename);
      $("#password").val(data.password);
    });
    function saveCurrAdmin() {
      console.log("Save current admin");
      var formData=$("#fm").serialize();

      $.ajax({
        type: "POST",
        url: "admins/1",
        processData:true,
        data:formData,
        success: function(result){
          if (result.code !== 0) {
            $.messager.alert("system prompt", result.message);
          } else {
            $.messager.alert("system prompt", "Save successful!");
          }
        }
      });

    }
  </script>
</head>
<body style="margin: 1px;">
  <form id="fm">
    <table cellspacing="8px">
      <input type="text" id="_method" name="_method" value="put" hidden="true"/>
      <tr>
        <td>Username:</td>
        <td><input type="text" id="username" name="username" value=""
                   class="easyui-validatebox"/>&nbsp
      </tr>
      <tr>
        <td>Rolename:</td>
        <td><input type="text" id="rolename" name="rolename" value=""
                   class="easyui-validatebox"/>
      </tr>
      <tr>
        <td>Password:</td>
        <td><input type="password" id="password" name="password" value=""
                   class="easyui-validatebox"/>
      </tr>

      <tr>
        <td></td>
        <td><input type="button" id="save" name="save" value="Save" onclick="javascript:saveCurrAdmin()"/>
      </tr>
    </table>
  </form>
</body>
</html>